#!/usr/bin/env python2.4
# WM2
"""WebMe - simple podcasting engine"""
__version__ = "0.1.0"
__license__ = "GNU Lesser General Public License, Ver.2"
__author__ = "Grigory Bakunov <bobuk@justos.org>"

import sys; sys.path.append('libs')
import web
import os
import form
import markdown

from config import *

from wmauth import *

from wmconfig import *

import wmtools
import wmforms
import wmtxt
import wmpodcast

urls = (
    '/',				'index',
    '/index',				'index',

    '/error/(\d+)',			'wmtools.error',
    '.*/ss/(.*)[/]*',			'wmtools.semistatic',
    '.*/ss/(.*)[/]*',			'wmtools.semistatic',
    '.*/player\.swf',			'wmtools.player',
    
    '/admin[/]*',			'wmadmin.admin',
    '/admin/logout',			'wmadmin.logout',
    '/admin/config',			'wmadmin.config',
    '/admin/users*',			'wmadmin.users',
    '/admin/user\.(\w+)\.remove',	'wmadmin.userDel',
    '/admin/user\.(\w+).\change',	'wmadmin.userChange',
    '/admin/newuser',		        'wmadmin.userNew',
    '/admin/txtmap',			'wmadmin.textList',


    '/txt\.(\w+)',			'wmtxt.text',
    '/txt\.(\w+)\.remove',		'wmtxt.deltext',

    '.*/forms\.(.*)',			'wmforms.forms',

    '.*/rss.*',				'wmpodcast.rss',              # universal rss feed
    '/podcast[/]*',			'wmpodcast.podcasts',         # Show podcast list
    '/pod/(\d+)[/]*',			'wmpodcast.podcast',          # Show/Edit Episode number N
    '/pod/(\d+)/del',			'wmpodcast.podcastDel',       # Remove Episode number N
    '/pod/new',				'wmpodcast.podcastNew',       # Add new Episode
    '/pod/(\d+)/comment',		'wmpodcast.podcastComment',   # Comment Episode (PUBLIC)
    '/pod/(\d+)/comment/(\d+)/del',	'wmpodcast.podcastCommentDel',# Remove comment N from Episode M

    '/files', 				'wmfiles.files',
)

web.internalerror = web.debugerror

###
# Main (and realy strange) functionality
###

            
class index:
    # Just redirect to txt.intro. It's so boring
    def GET(self):
        web.redirect(Config().cfg['c_abspath'] + '/txt.intro')


if __name__ == '__main__':
    web.db_parameters = database
    web.run(urls, web.reloader)
